const koa = require('koa');
const mysql = require('./libs/koa-better-mysql');

let db=mysql.createPool({
    host:'loacalhost',
    user:'root',
    password:'',
    port:3306,
    database:'an_ju_ke'
})


let server=new koa();
server.listen(8080);

server.use(async ctx=>{
    let datas=await db.query('SELECT * FROM house_table');

    // 开始的写法

    let datas = await new Promise((resolve,reject)=>{
        let fn= db.query('SELECT * FROM house_table');
        fn(function(err,data){
            if(err){
                reject(err)
            }else{
                resolve(data)
            }
        })
    })


    console.log(datas);
})